import { request } from '@/utils/request'
import type { ApiResponse, HttpMethod } from '@/types/global'

interface BannerResponse {
    id: number
    title: string
    image: string
    url: string
}

export interface loginParams {
    username: string
    password: string
}

export interface loginResponse {
    username: string
    password: string
    token: string
}

export const apiBanner = (params: any, method: HttpMethod = 'GET'): Promise<ApiResponse<BannerResponse>> => {
    return request('/banners', params, method)
}

export const login = (data: loginParams) => request('/login', data, 'POST')

// export const login = (data: loginParams): Promise<ApiResponse<loginResponse>> => request('/login', data, 'POST')
export const logout = () => request('/logout', {}, 'POST')
export const getUserInfo = () => request('/me', {}, 'GET')

export const getUserList = (params: any) => request('/user/list', params, 'GET')
export const getUserDetail = (id: number) => request(`/user/${id}`, {}, 'GET')
export const addUser = (data: any) => request('/user', data, 'POST')
export const updateUser = (data: any) => request(`/user/${data.id}`, data, 'PUT')
export const deleteUser = (id: number) => request(`/user/${id}`, {}, 'DELETE')
